﻿//using DzInfo.Tools;
//using Kingdee.BOS.Core.DynamicForm.PlugIn;
//using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
//using Kingdee.BOS.Core.Metadata;
//using Kingdee.BOS.Orm.DataEntity;
//using Kingdee.BOS.ServiceHelper;
//using Kingdee.BOS.Util;
//using System;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace DzInfo.SerivesPlugin.ZhuMuNiao
//{
//    [Description("zmn销售订单、发货通知单保审核和反审核反写付款单关联金额"), HotUpdate]
//    public class fhAudit : AbstractOperationServicePlugIn
//    {
//        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
//        {
//            base.AfterExecuteOperationTransaction(e);
//            var opNumber = this.FormOperation.Operation;
//            var formId = this.BusinessInfo.GetForm().Id;
//            if (opNumber.Equals("Audit"))
//            {
//                if (formId.Equals(KdFomId.SAL_SaleOrder.ToString()))
//                {
//                    var obj = e.DataEntitys.FirstOrDefault();
//                    decimal jshj = GetJSHJ(obj);
//                    DynamicObject cust = obj["CustId"] as DynamicObject;
//                    DynamicObject custJDZC = cust == null ? null : cust["F_POSW_Assistant_27t"] as DynamicObject;
//                    string jdzcNumber = custJDZC == null ? "" : Convert.ToString(custJDZC["number"]);
//                    SalAuditFX(jdzcNumber, obj, jshj);
//                }
//                if (formId.Equals(KdFomId.SAL_DELIVERYNOTICE.ToString()))
//                {
//                    var obj = e.DataEntitys.FirstOrDefault();
//                    decimal jshj = GetJSHJ(obj);
//                    DynamicObject cust = obj["CustId"] as DynamicObject;
//                    DynamicObject custJDZC = cust == null ? null : cust["F_POSW_Assistant_27t"] as DynamicObject;
//                    string jdzcNumber = custJDZC == null ? "" : Convert.ToString(custJDZC["number"]);
//                    fhAuditFX(jdzcNumber, obj);
//                }
//            }
//            if (opNumber.Equals("UnAudit"))
//            {
//                if (formId.Equals(KdFomId.SAL_SaleOrder.ToString()))
//                {
//                    var obj = e.DataEntitys.FirstOrDefault();
//                    decimal jshj = GetJSHJ(obj);
//                    DynamicObject cust = obj["CustId"] as DynamicObject;
//                    DynamicObject custJDZC = cust == null ? null : cust["F_POSW_Assistant_27t"] as DynamicObject;
//                    string jdzcNumber = custJDZC == null ? "" : Convert.ToString(custJDZC["number"]);
//                    SalUnAuditFX(jdzcNumber, obj);
//                }
//                if (formId.Equals(KdFomId.SAL_DELIVERYNOTICE.ToString()))
//                {
//                    var obj = e.DataEntitys.FirstOrDefault();
//                    decimal jshj = GetJSHJ(obj);
//                    DynamicObject cust = obj["CustId"] as DynamicObject;
//                    DynamicObject custJDZC = cust == null ? null : cust["F_POSW_Assistant_27t"] as DynamicObject;
//                    string jdzcNumber = custJDZC == null ? "" : Convert.ToString(custJDZC["number"]);
//                    fhUnAuditFX(jdzcNumber, obj);
//                }
//            }
//        }
//        /// <summary>
//        /// 发货通知单反审核反写
//        /// </summary>
//        /// <param name="jdzcNumber"></param>
//        /// <param name="obj"></param>
//        /// <exception cref="NotImplementedException"></exception>
//        private void fhUnAuditFX(string jdzcNumber, DynamicObject obj)
//        {
//            throw new NotImplementedException();
//        }

//        /// <summary>
//        /// 销售订单反审核反写
//        /// </summary>
//        /// <param name="jdzcNumber"></param>
//        /// <param name="obj"></param>
//        /// <exception cref="NotImplementedException"></exception>
//        private void SalUnAuditFX(string jdzcNumber, DynamicObject obj)
//        {
//            throw new NotImplementedException();
//        }

//        /// <summary>
//        /// 发货通知单审核反写
//        /// </summary>
//        /// <param name="jdzcNumber"></param>
//        /// <param name="obj"></param>
//        /// <exception cref="NotImplementedException"></exception>
//        private void fhAuditFX(string jdzcNumber, DynamicObject obj)
//        {
//            throw new NotImplementedException();
//        }
//        /// <summary>
//        /// 销售订单审核反写
//        /// </summary>
//        /// <param name="jdzcNumber"></param>
//        /// <param name="obj"></param>
//        /// <exception cref="NotImplementedException"></exception>
//        private void SalAuditFX(string jdzcNumber, DynamicObject obj, decimal jshj)
//        {
//            DynamicObjectCollection ysRow = obj["POSW_Cust_Entry100001"] as DynamicObjectCollection;
//            var fkdBillno = ysRow.Select(s => Convert.ToString(s["F_POSW_Text_jtv"])).ToList();
//            foreach (var fk in fkdBillno)
//            {
//                var list = fk.Split(',').ToList();
//                foreach (var item in list)
//                {
//                    decimal skdje = GetSK(item);
//                }
//            }
//        }

//        private decimal GetSK(string no)
//        {
//            decimal sk = 0;

//            return sk;
//        }

//        private decimal GetJSHJ(DynamicObject obj)
//        {
//            decimal xs = 0;
//            DynamicObjectCollection fine = obj["SaleOrderFinance"] as DynamicObjectCollection;
//            xs = Convert.ToDecimal(fine[0]["BillAllAmount"]);
//            return xs;
//        }

//        /// <summary>
//        /// 加载所有列
//        /// </summary>
//        /// <param name="e"></param>
//        public override void OnPreparePropertys(PreparePropertysEventArgs e)
//        {
//            base.OnPreparePropertys(e);
//            FormMetadata meta = MetaDataServiceHelper.GetFormMetaData(this.Context, this.BusinessInfo.GetForm().Id);
//            var fieldKeyList = meta.BusinessInfo.GetBosFields().Select(x => x.Field.Key).ToList();
//            for (int i = 0; i < fieldKeyList.Count; i++)
//            {
//                e.FieldKeys.Add(fieldKeyList[i]);
//            }
//        }
//    }
//}
